package IO.chars;
import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;

public class TestReader {
    public static void main(String[] args) {

        try(Reader reader = new FileReader("d:/test.txt")){

            while (true) {
                char[] buffer = new char[1024];
                int len = reader.read(buffer);
                if (len == -1) {
                    break;// 读完了
                }
//                for (int i = 0; i < len; i++) {
//                    System.out.println(buffer[i]);
//                }
//                 如果传入的是byte数组,就可以指定编码
//                String s = new String(buffer,0,len,"uft8");
                String s = new String(buffer,0,len);
                System.out.println(s);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}